/**
 * Filename: TimeCompassActivity.java
 *
 * @author Firefly
 * @contact postfirefly@163.com
 * @time 2016/5/20 10:23
 */
package com.github.postsanf.yinian.activity;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import com.github.postsanf.yinian.BaseActivity;
import com.github.postsanf.yinian.R;
import com.umeng.analytics.MobclickAgent;

/**
 *  时光罗盘
 */
public class TimeCompassActivity extends BaseActivity implements View.OnClickListener {
    private int[] mAnimationViewIds = {
            R.id.iv_timeline_ball1, R.id.iv_timeline_ball2,
            R.id.iv_timeline_ball3, R.id.iv_timeline_ball4, R.id.rl_timeline_start
    };

    private Handler handler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.yn_activity_time_compass);
        initView();
    }

    private void initView() {
        handler.postDelayed(mRunnableBall, 1000);
    }

    private Runnable mRunnableBall = new Runnable() {
        @Override
        public void run() {
            doBallAnim();
        }
    };

    private void doBallAnim() {
        findViewById(mAnimationViewIds[0]).startAnimation(getBallAnimation(R.anim.anim_stars_rotate));
        findViewById(mAnimationViewIds[1]).startAnimation(getBallAnimation(R.anim.anim_stars_ball2));
        findViewById(mAnimationViewIds[2]).startAnimation(getBallAnimation(R.anim.anim_stars_ball3));
        findViewById(mAnimationViewIds[3]).startAnimation(getBallAnimation(R.anim.anim_stars_ball4));
        findViewById(mAnimationViewIds[4]).startAnimation(getBallAnimation(R.anim.anim_stars_start));
    }

    private Animation getBallAnimation(int resID) {
        Animation animation = AnimationUtils.loadAnimation(this, resID);
        return animation;
    }

    @Override
    public void onClick(View v) {
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    // 友盟统计
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart(this.getClass().getSimpleName());
        MobclickAgent.onResume(this);
    }

    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd(this.getClass().getSimpleName());
        MobclickAgent.onPause(this);
    }


}
